// (C) Copyright 2012 Enlightv. All rights reserved.

`timescale 1ns/100ps

module comparator
#(parameter
    BW = 8
)
(
    input  [ BW - 1: 0] I_a,
    input  [ BW - 1: 0] I_b,
    output O_greater,
    output O_greater_or_equal,
    output O_less,
    output O_less_or_equal
);

/******************************************************************************
                                <localparams>
******************************************************************************/

/******************************************************************************
                              <internal signals>
******************************************************************************/
wire signed [ BW : 0] diff;
wire equal;

/******************************************************************************
                                <module body>
******************************************************************************/
assign diff = $signed({1'b0,I_a}) - $signed({1'b0,I_b});
assign equal = I_a == I_b;

assign O_greater = diff[BW] == 1'b0 && !equal;

assign O_greater_or_equal = diff[BW] == 1'b0;

assign O_less = diff[BW] == 1'b1;

assign O_less_or_equal = diff[BW] == 1'b1 || equal;

endmodule

